<?php

namespace app\common\model;

use think\Model;

/**
 * @property int $total_amount
 * @property int $discount_amount
 * @property int $amount_payable
 */
abstract class OrderCommon extends Model
{
    public function getPaymentBody(): string
    {
        return '城市牧场订单';
    }

    public function refundDesc(): string
    {
        return '用户退款';
    }

    public function getTotalAmountAttr($value)
    {
        return $value / 100;
    }

    public function setTotalAmountAttr($value)
    {
        return $value * 100;
    }

    public function getPaidAmountAttr($value)
    {
        return $value / 100;
    }

    public function setPaidAmountAttr($value)
    {
        return $value * 100;
    }

    public function getDiscountAmountAttr($value)
    {
        return $value / 100;
    }

    public function setDiscountAmountAttr($value)
    {
        return $value * 100;
    }

    /**应付金额 to 微信
     * @return void
     */
    public function getAmountPayableAttr($value, $data): float
    {
        return $this->getData('order_amount') * 100;
    }

    /**
     * @return float
     */
    public function getAmountViewAttr()
    {
        return $this->amount_payable / 100;
    }
}